Friend Class DBScanSchedule
    Inherits DBBase

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub Load(ByRef oObject As SQLAutoDocLib.ScanSchedule)
        Dim sSQL As String = "select"
        sSQL = sSQL & "     a.[ServerID],"
        sSQL = sSQL & "     a.[DatabaseID],"
        sSQL = sSQL & "     a.[ScanTypeID],"
        sSQL = sSQL & "     a.[ScanTypeIntervalMinutes],"
        sSQL = sSQL & "     a.[SendReport],"

        sSQL = sSQL & "     a.[CreateName],"
        sSQL = sSQL & "     a.[CreateDate],"
        sSQL = sSQL & "     a.[ChangeName],"
        sSQL = sSQL & "     a.[ChangeDate]"
        sSQL = sSQL & " from"
        sSQL = sSQL & "     ScanSchedule a"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     a.[ID]=" & oObject.ID

        Dim oData As DataTable = MyBase.ExecuteReadToDataTable(sSQL)

        If oData.Rows.Count > 0 Then
            With oObject
                .ServerID = oData.Rows(0).Item("ServerID")
                .DatabaseID = oData.Rows(0).Item("DatabaseID")
                .ScanTypeID = oData.Rows(0).Item("ScanTypeID")
                .ScanTypeMinutes = oData.Rows(0).Item("ScanTypeIntervalMinutes")
                .SendReport = oData.Rows(0).Item("SendReport")

                .CreateName = oData.Rows(0).Item("CreateName")
                .CreateDate = oData.Rows(0).Item("CreateDate")
                .ChangeName = NullToString(oData.Rows(0).Item("ChangeName"))
                .ChangeDate = NullToString(oData.Rows(0).Item("ChangeDate"))
            End With
        End If

        oData.Dispose()
    End Sub

    Public Sub Update(ByRef oObject As SQLAutoDocLib.ScanSchedule)
        Dim sSQL As String = "update ScanSchedule set"
        sSQL = sSQL & "     [ServerID]=" & ValueToDBValue(oObject.ServerID) & ","
        sSQL = sSQL & "     [DatabaseID]=" & ValueToDBValue(oObject.DatabaseID) & ","
        sSQL = sSQL & "     [ScanTypeID]=" & ValueToDBValue(Val(oObject.ScanTypeID)) & ","
        sSQL = sSQL & "     [ScanTypeIntervalMinutes]=" & ValueToDBValue(oObject.ScanTypeMinutes) & ","
        sSQL = sSQL & "     [SendReport]=" & BooleanToBit(oObject.SendReport) & ","

        sSQL = sSQL & "     [CreateName]=" & ValueToDBValue(oObject.CreateName) & ","
        sSQL = sSQL & "     [CreateDate]=" & ValueToDBValue(oObject.CreateDate) & ","
        sSQL = sSQL & "     [ChangeName]=" & ValueToDBValue(oObject.ChangeName) & ","
        sSQL = sSQL & "     [ChangeDate]=" & ValueToDBValue(oObject.ChangeDate)
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [ID]=" & oObject.ID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub Add(ByRef oObject As SQLAutoDocLib.ScanSchedule)
        Dim sSQL As String = "insert into ScanSchedule ("
        sSQL = sSQL & "     [ID],"
        sSQL = sSQL & "     [ServerID],"
        sSQL = sSQL & "     [DatabaseID],"
        sSQL = sSQL & "     [ScanTypeID],"
        sSQL = sSQL & "     [ScanTypeIntervalMinutes],"
        sSQL = sSQL & "     [SendReport],"

        sSQL = sSQL & "     [CreateName],"
        sSQL = sSQL & "     [CreateDate],"
        sSQL = sSQL & "     [ChangeName],"
        sSQL = sSQL & "     [ChangeDate]) values ("

        sSQL = sSQL & ValueToDBValue(oObject.ID) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ServerID) & ","
        sSQL = sSQL & ValueToDBValue(oObject.DatabaseID) & ","
        sSQL = sSQL & ValueToDBValue(Val(oObject.ScanTypeID)) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ScanTypeMinutes) & ","
        sSQL = sSQL & BooleanToBit(oObject.SendReport) & ","

        sSQL = sSQL & ValueToDBValue(oObject.CreateName) & ","
        sSQL = sSQL & ValueToDBValue(oObject.CreateDate) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ChangeName) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ChangeDate) & ")"

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub Delete(ByRef oObject As SQLAutoDocLib.ScanSchedule)
        Dim sSQL As String = "delete from ScanSchedule"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [ID]=" & oObject.ID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub
End Class
